﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BatDongSan.Modules
{
    public partial class Uct_Header : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                Advertisement1.LoadBannerList(14, 1, "730", "0px");
            if (Request.Cookies["DiaOcDaNang"] != null)
            {
                if (Request.Cookies["DiaOcDaNang"]["IdMember"] != null && Request.Cookies["DiaOcDaNang"]["IdMember"].ToString()!="")
                {
                    pnLogin.Visible = false;
                    pnName.Visible = true;
                    hplUserName.Text = Convert.ToString(Request.Cookies["DiaOcDaNang"]["NameMember"]);
                }
                else
                {
                    pnLogin.Visible = true;
                    pnName.Visible = false;
                }
            }
            else
            {
                pnLogin.Visible = true;
                pnName.Visible = false;
            }
        }

        protected void lkbLogout_Click(object sender, EventArgs e)
        {
            HttpCookie myCookie = new HttpCookie("DiaOcDaNang");
            myCookie["IdMember"] = null;
            myCookie["NameMember"] = null;
            myCookie.Expires = DateTime.Now.AddDays(60);
            Response.Cookies.Add(myCookie);
            Response.Redirect("~/Login.aspx");           
        }
    }
}